package pe.gob.inei.sirtod.repository.impl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import pe.gob.inei.sirtod.domain.Anio;
import pe.gob.inei.sirtod.repository.AnioDAO;
import pe.gob.inei.sirtod.util.Frecuencia;

@Repository(value = "anioDAO")
public class SIRTODAnio implements AnioDAO {

	@Autowired
	private SessionFactory sessionFactory;

	@Transactional(readOnly = true)
	@SuppressWarnings("unchecked")
	public List<Anio> findAll(Frecuencia frecuencia, List<String> lisIndSel) {
		Query query = sessionFactory.getCurrentSession().getNamedQuery(frecuencia.getQuery());
		query.setParameterList("lisIndSel", lisIndSel);
		return query.list();
	}
}
